package threadTest;

import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class maximumPoolSizeTest {
    public static void main(String[] args) {
        // CPU 密集型 ,会充分的利用CPU资源
        System.out.println(String.format("系统CPU 核数大小,%d",Runtime.getRuntime().availableProcessors()));

        ThreadPoolExecutor pool = new ThreadPoolExecutor(2,
                                                         Runtime.getRuntime().availableProcessors(),
                                                         0L,
                                                         TimeUnit.MILLISECONDS,
                                                         new LinkedBlockingQueue<Runnable>(1000),
                                                         Executors.defaultThreadFactory(),
                                                         new ThreadPoolExecutor.CallerRunsPolicy()); // CallerRunsPolicy() 拒绝策略谁提交的 谁认领走

        // IO 密集型  , 有15个任务 及其耗费 IO资源    那么就设置为30 2倍 ,保证还有15个 线程可以使用

        List<String> lists  = new LinkedList<>();

    }
}
